package com.xggstudio.crm.ui.mvp.v;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.xggstudio.crm.R;
import com.xggstudio.crm.base.BaseActivity;
import com.xggstudio.crm.ui.mvp.p.P_login;

public class LoginActivity extends BaseActivity implements ILogin {

    private Toolbar toolbar;

    private EditText user;
    private EditText pwd;

    private P_login pLogin;

    @Override
    protected int getLayout() {
        return R.layout.activity_login;
    }

    @Override
    protected void init(Bundle savedInstanceState) {

        toolbar = (Toolbar) $(R.id.toolbar);
        user = (EditText) $(R.id.user);
        pwd = (EditText) $(R.id.pwd);
        setToolbar();

        user.setText("admin@eduxgg.com");
        pwd.setText("xiaoguigui520");

        pLogin = new P_login(this);
    }

    private void setToolbar(){

        toolbar.setTitle("");
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    public void onClick(View v){
        switch (v.getId()){
            case R.id.login:
                //startToActivity(MainActivity.class);
                pLogin.login(user.getText().toString(),pwd.getText().toString());
                break;
            case R.id.findpwd:

                break;


        }
    }


    @Override
    public void toMain() {
        startToActivity(MainActivity.class);
    }

    @Override
    public void showWaring(String s) {
        Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
    }
}
